/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Figuras;

import java.awt.*;
import java.awt.Color;
import java.awt.Graphics;
import java.util.TreeMap;

/**
 *
 * @author Administrador
 */
public class Movil extends Figura{
    TreeMap<Integer,Integer> tc;

    public Movil(Integer x0, Integer y0, Integer w0, Integer h0, Color c,
        Lienzo l){
        super(x0, y0, w0, h0, c, l); 
    }

    @Override
    public void dibujate(Graphics g) {
        Class[] arg =new Class[1];
        arg[0]= Graphics2D.class;
        Graphics2D g2= (Graphics2D)g;
        int y1=y+h/2;
        int x1=x+w/2;
        g2.rotate((Math.PI/2)*orientacion,x1,y1);

        float[] res=new float[3];
        res=this.color.getColorComponents(null);
        Image p=null;
  
        if((int)(res[0]*10)==0 && (int)(res[1]*10)==10 && (int)(res[2]*10)==10){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanquec.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==10 && (int)(res[2]*0)==0){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanqueam.jpg");
        }
        if((int)(res[0]*10)==0 && (int)(res[1]*10)==0 && (int)(res[2]*10)==10){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanquea.jpg");
        }
        if((int)(res[0]*10)==0 && (int)(res[1]*10)==10 && (int)(res[2]*0)==0){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanquev.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==6 && (int)(res[2]*10)==6){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanque.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==7 && (int)(res[2]*10)==0){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanqueinv.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==10 && (int)(res[2]*10)==10){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanqueb.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==0 && (int)(res[2]*10)==10){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanqueinve.jpg");
        }
        if((int)(res[0]*10)==10 && (int)(res[1]*10)==0 && (int)(res[2]*10)==0){
            p = Toolkit.getDefaultToolkit().getImage("imagenes//tanquerojo.jpg");
        }
        g2.drawImage(p, x, y,w, h,lienzo);
        g2.rotate(-(Math.PI/2)*orientacion,x1,y1);
    }

    @Override
    public void colisionoCon(CirculoBomba c) {
        this.pierdeVida(-1);
        c.pierdeVida(-1);

    }

    @Override
    public void colisionoCon(Cuadrilatero c) {

    }

    @Override
    public void colisionoCon(Figura c) {
        c.colisionoCon(this);
    }

    @Override
    public void colisionoCon(Pared c) {

    }

    @Override
    public void colisionoCon(Bala c) {
        this.pierdeVida(-1);
        c.pierdeVida(-1);
    }

    @Override
    public void colisionoCon(Movil c) {
        x-=dx;
        y-=dy;
        dy=0;
        dx=0;
    }

    @Override
    public void colisionoCon(ParedH c) {
    }

    @Override
    public void colisionoCon(ParedV c) {

    }
    @Override
    public String toString(){
        return "Movil";
    }

    public void choquePared(){
        x-=dx;
        y-=dy;
        dy=0;
        dx=0;
    }

    @Override
    public void colisionoCon(CirculoVida c) {
        this.pierdeVida(1);
        c.pierdeVida(-1);
    }

}
